﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Areas/SystemManage/Views/Shared/_Form.cshtml";
}

<script src="~/js/jqgrid/jqgrid.min.js"></script>
<link href="~/js/jqgrid/jqgrid.css" rel="stylesheet" />
<script src="~/js/jqgrid/grid.locale-cn.js"></script>
<script>
    var keyValue = $.request("keyValue");
    $(function () {
        //获取基本信息展示
        $.ajax({
            url: "/SystemManage/SysMember/GetFormJson",
            data: { keyValue: keyValue },
            dataType: "json",
            async: false,
            success: function (data) {
                $("#RealName").html(data.RealName);
                $("#MobilePhone").html(data.MobilePhone);
                $("#Telephone").html(data.Telephone);
                $("#Birthday").html(data.Birthday);
                $("#Address").html(data.Address);
                $("#Company").html(data.Company);
               // $("#GroupId").html(data.GroupId);
                $("#Tax").html(data.Tax);
                $("#HomePhone").html(data.HomePhone);
                $("#Email").html(data.Email);
                $("#ZipCode").html(data.ZipCode);
                $("#Position").html(data.Position);
                $("#Description").html(data.Description);
                //$("#form1").formSerialize(data);

                $.getJSON("/SystemManage/SysMemGroup/GetTreeSelectJson?groupid=" + data.GroupId, function (result) { 
                    if (result.length > 0) {
                        $("#GroupId").html(result[0].text);
                    }
                })


                gridList(data.MobilePhone + "-" + data.Telephone);
            }
        });
    });

    function gridList(mobile) {
        console.log(mobile);
        var $gridList = $("#gridList");
        var pageUrl = "/SystemManage/SkyVoice/GetMemGridJson?MemPhone=" + encodeURI(mobile);
        console.log(pageUrl);
        $gridList.dataGrid({
            url: pageUrl,
            height: $(window).height() - 96,
            colModel: [
                { label: "主键", name: "Id", hidden: true, key: true },
                {
                    label: '本地通道', name: 'LineNumber', width: 40, align: 'left'
                },
                { label: '对方号码', name: 'PhoneNumber', width: 100, align: 'left' },
                {
                    label: '方向', name: 'Direction', width: 80, align: 'left',
                    formatter: function (cellvalue) {
                        if (cellvalue == "I") {
                            return "拨入";
                        }
                        else if (cellvalue == "O") {
                            return "拨出";
                        }
                        return "手动";
                    }
                },
                { label: '挂断', name: 'CutLine', width: 30, align: 'left' },
                { label: '类型', name: 'Type', width: 20, align: 'left' },
                {
                    label: '时间', name: 'FileDate', width: 100, align: 'left',
                    formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i', newformat: 'Y-m-d H:i' }
                },
                { label: '通话时长', name: 'LineTime', width: 70, align: 'left' },
                { label: '备注', name: 'Description', width: 80, align: 'left' },
                { label: '文件', name: 'VoiceFile', width: 100, align: 'left' }
                //,
                //{
                //    label: '创建时间', name: 'CreatorTime', width: 100, align: 'left',
                //    formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i', newformat: 'Y-m-d H:i' }
                //}
            ]
            //, onSortCol: function (index, colindex, sortorder) {
            //    //列排序事件
            //    var data = $("#searchform").serialize();
            //    if (data.length > 0) {
            //        data += "&";
            //    }
            //    data += "SortColumn=" + index + "&SortOrder=" + sortorder;
            //    console.log(data);
            //    $gridList.jqGrid('setGridParam', {
            //        postData: data,
            //    }).trigger('reloadGrid');
            //}
        });
    }
</script>
<form id="form1">
    <table class="form">
        <tr>
            <th class="formTitle">姓名：</th>
            <td class="formValue">
                <label type="text" id="RealName" name="RealName" class="required" placeholder="请输入姓名" />
            </td>
            <th class="formTitle">手机：</th>
            <td class="formValue">
                <label type="text" id="MobilePhone" name="MobilePhone" class=" required isPhone" />
            </td>
            <th class="formTitle">电话：</th>
            <td class="formValue">
                <label type="text" id="Telephone" name="Telephone" class=" isTel" />
            </td>
            <th class="formTitle">生日：</th>
            <td class="formValue" style="width:120px">
                <label type="text" id="Birthday" name="Birthday" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">地址：</th>
            <td class="formValue">
                <label type="text" id="Address" name="Address" class="" />
            </td>
            <th class="formTitle">单位：</th>
            <td class="formValue">
                <label type="text" id="Company" name="Company" class="" />
            </td>
            <th class="formTitle">分组：</th>
            <td class="formValue">
                <label id="GroupId" name="GroupId" class="required"></label>
            </td>
            <th class="formTitle">传真：</th>
            <td class="formValue">
                <label id="Tax" name="Tax" type="text" class="" placeholder="请输入传真" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">宅电：</th>
            <td class="formValue">
                <label id="HomePhone" name="HomePhone" type="text" class="" placeholder="请输入宅电" />
            </td>
            <th class="formTitle">邮箱：</th>
            <td class="formValue">
                <label type="text" id="Email" name="Email" class=" email" />
            </td>
            <th class="formTitle">邮编：</th>
            <td class="formValue">
                <label type="text" id="ZipCode" name="ZipCode" class="" />
            </td>
            <th class="formTitle">职务：</th>
            <td class="formValue">
                <label type="text" id="Position" name="Position" class="" />
            </td>
            <th class="formTitle">备注：</th>
            <td class="formValue">
                <label id="Description" name="Description" class="" style="height: 60px;"></label>
            </td>
        </tr>
    </table>
    <div class="gridPanel">
        <table id="gridList"></table>
    </div>
</form>
